package com.hsnn.medstgmini.settlement.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hsnn.medstgmini.base.std.model.StdHealthbureau;
import com.hsnn.medstgmini.settlement.dao.SetPaynoticeDao;
import com.hsnn.medstgmini.settlement.model.SetAcctInfo;
import com.hsnn.medstgmini.settlement.model.SetRelationship;
import com.hsnn.medstgmini.settlement.service.SetPaynoticeManager;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;




@Service
public class SetPaynoticeManagerImpl implements SetPaynoticeManager {

		@Autowired
		private SetPaynoticeDao setPaynoticeDao;
	/**
	 * 缴款通知书[中心端]
	 * 徐国鹏
	 */
	@Override
	public Pagination getSettleInfoList(Pagination page) {
		
		page = setPaynoticeDao.getSettleInfoList(page);
		@SuppressWarnings("unchecked")
		List<Map<String, Object>> list = (List<Map<String, Object>>) page
				.getRows();
		if (null != list && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> map = list.get(i);
				map.put("scheduleBegTime",
						map.get("scheduleBegTime") == null ? "" : ParseDate
								.parseFullFormat(ParseDate.fromFullFormat(map
										.get("scheduleBegTime").toString())));
				map.put("scheduleEndTime",
						map.get("scheduleEndTime") == null ? "" : ParseDate
								.parseFullFormat(ParseDate.fromFullFormat(map
										.get("scheduleEndTime").toString())));
			}
		}
		return page;
	}
	
	/**
	 * 缴款通知书[医疗机构端]
	 * 徐国鹏
	 */
	@Override
	public Pagination getSettleInfoListyy(Pagination page) {

		page = setPaynoticeDao.getSettleInfoListyy(page);
		@SuppressWarnings("unchecked")
		List<Map<String, Object>> list = (List<Map<String, Object>>) page
				.getRows();
		if (null != list && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> map = list.get(i);
				map.put("scheduleBegTime",
						map.get("scheduleBegTime") == null ? "" : ParseDate
								.parseFullFormat(ParseDate.fromFullFormat(map
										.get("scheduleBegTime").toString())));
				map.put("scheduleEndTime",
						map.get("scheduleEndTime") == null ? "" : ParseDate
								.parseFullFormat(ParseDate.fromFullFormat(map
										.get("scheduleEndTime").toString())));
			}
		}
		return page;
	}

	@Override
	public Pagination getSettleInfoLisths(Pagination page) {
		
		page = setPaynoticeDao.getSettleInfoLisths(page);
		return page;
	}
	//////	//////	//////	//////	//////	//////	//////	//////	//////
	/**
	 * 缴款通知书详情[医疗机构端]
	 */
	public Pagination getSetPaynoticeDetailList(Pagination page) {
		page = setPaynoticeDao.getSetPaynoticeDetailList(page);
		 return page; 
//		 List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
//		 if (null != list && list.size() > 0){
//			 for (int i = 0; i < list.size(); i++){
//				 Map<String, Object> map = list.get(i);
//				 if (null == map.get("delDetailId")){
//					 map.put("delDetailId", "");
//				 }
//				 /*if (null == map.get("goodsCode")){
//					 map.put("goodsCode", "");
//				 }*/
//				 map.put("delDetailId",
//							map.get("delDetailId") == null ? "" : map.get("delDetailId")
//									.toString());
//				 map.put("goodsCode",
//							map.get("goodsCode") == null ? "" : map.get("goodsCode")
//									.toString());
//				 map.put("settleSchBegTime",
//							map.get("settleSchBegTime") == null ? "" : ParseDate
//									.parseFullFormat(ParseDate.fromFullFormat(map
//											.get("settleSchBegTime").toString())));
//				 map.put("settleSchEndTime",
//							map.get("settleSchEndTime") == null ? "" : ParseDate
//									.parseFullFormat(ParseDate.fromFullFormat(map
//											.get("settleSchEndTime").toString())));
//				 
//			 }
//			 page.setRows(list);
//		 }
		
	}
	/**
	 * 缴款通知书详情[核算中心]
	 */
	@Override
	public Pagination getSetPaynoticehsDetailList(Pagination page) {
		page = setPaynoticeDao.getSetPaynoticehsDetailList(page);
		 return page; 
	 }
	/**
	 * 缴款通知书详情[中心端]
	 */
	public Pagination getSetPaynoticeDetailListzx(Pagination page) {
		page = setPaynoticeDao.getSetPaynoticeDetailListzx(page);
		 @SuppressWarnings("unchecked")
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		 if (null != list && list.size() > 0){
			 for (int i = 0; i < list.size(); i++){
				 Map<String, Object> map = list.get(i);
				 if (null == map.get("delDetailId")){
					 map.put("delDetailId", "");
				 }
				 map.put("goodsCode",map.get("goodsCode") == null ? "" : map.get("goodsCode").toString());
				 
			 }
			 page.setRows(list);
		 }
		 return page; 
	}
	
	/**
	  * @category 获取缴款通知书列表[卫生局]
	  * @Auther 周奇
	  * @date 2015年8月6日15:52:11
	  * @param page
	  * @return Pagination
	  */
	@Override
	public Pagination getPaynoticListForHeathBeau(Pagination page) {
		page = setPaynoticeDao.getPaynoticListForHeathBeau(page);
		@SuppressWarnings("unchecked")
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		 if (null != list && list.size() > 0){
			 for (int i = 0; i < list.size(); i++){
				 Map<String, Object> map = list.get(i);
				 map.put("scheduleBegTime",
							map.get("scheduleBegTime") == null ? "" : ParseDate
									.parseFullFormat(ParseDate.fromFullFormat(map
											.get("scheduleBegTime").toString())));
				 map.put("scheduleEndTime",
							map.get("scheduleEndTime") == null ? "" : ParseDate
									.parseFullFormat(ParseDate.fromFullFormat(map
											.get("scheduleEndTime").toString())));
				 
			 }
			 page.setRows(list);
		 }
		 return page; 
	 }
	/**
	  * @category 获取缴款通知书详细列表[卫生局]
	  * @Auther 周奇
	  * @date 2015年8月6日15:52:11
	  * @param page
	  * @return Pagination
	  */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination getPaynoticDetailForHeathBeau(Pagination page){
		page = setPaynoticeDao.getPaynoticDetailForHeathBeau(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page.getRows();
		 if (null != list && list.size() > 0){
			 for (int i = 0; i < list.size(); i++){
				 Map<String, Object> map = list.get(i);
				 map.put("settleSchBegTime",
							map.get("settleSchBegTime") == null ? "" : ParseDate
									.parseFullFormat(ParseDate.fromFullFormat(map
											.get("settleSchBegTime").toString())));
				 map.put("settleSchEndTime",
							map.get("settleSchEndTime") == null ? "" : ParseDate
									.parseFullFormat(ParseDate.fromFullFormat(map
											.get("settleSchEndTime").toString())));
				 
			 }
			 page.setRows(list);
		 }
		 return page; 
	}

	@Override
	public StdHealthbureau getStdHealthbureauById(String id) {
		return setPaynoticeDao.getStdHealthbureauById(id);
	}


	@Override
	public Object getSetPaynoticeById(String id) {
		return setPaynoticeDao.getSetPaynoticeById(id);
	}

	@Override
	public SetAcctInfo getSetAcctInfoById(String id) {
		return setPaynoticeDao.getSetAcctInfoById(id);
	}

	@Override
	public SetRelationship getSetRelationshipById(String id) {
		return setPaynoticeDao.getSetRelationshipById(id);
	}
	
}